package com.woniuxy.yuekeuser.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.yuekeuser.model.City;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Freedom
 * @since 2020-11-03
 */
public interface CityMapper extends BaseMapper<City> {

    @Select("<script>" +
            " SELECT\n" +
            "city.city_id,\n" +
            "city.city_name,\n" +
            "city.city_heat,\n" +
            "city.city_picture_address\n" +
            "FROM\n" +
            "city " +
            " <where>" +
            "<if test='cityName!=null'>" +
            " and city_name = #{cityName} " +
            " </if>" +
            " </where>" +
            " order by city_heat desc" +
            " </script>" +
            "")
    public IPage<City> findAllCity(Page<City> cityPage, String cityName);

    @Select("SELECT\n" +
            "city.city_id,\n" +
            "city.city_name,\n" +
            "city.city_heat,\n" +
            "city.city_picture_address\n" +
            "FROM\n" +
            "city\n")
    public List<City> findAllCitys();
}
